package com.android.yinghebike.utils;

import android.content.Context;
import android.location.LocationManager;

import com.android.baselibrary.util.Util;

public class Utils {

    //计算距离
    public static String getDistance(double totalDistance)
    {
        String str = "";
        if(totalDistance>1000)
        {
            str = Util.formatDouble(totalDistance/1000d,1,0) +" km";
        }
        else
        {
            str = totalDistance+ " m";
        }
        return str;

    }


    public static boolean isLocationEnabled(Context context) {
        LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        boolean networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        return gpsEnabled || networkEnabled;
    }


}
